package DetailedLock;

/**
 * @projectName: JUC
 * @package: DetailedLock
 * @className: lockdemo
 * @author: 冷环渊 doomwatcher
 * @description: TODO
 * @date: 2022/3/5 2:17
 * @version: 1.0
 */
public class lockdemo {
    public static void main(String[] args) {
        phone phone = new phone();
        new Thread(() -> {
            phone.sms();
        }, "a").start();
        new Thread(() -> {
            phone.sms();
        }, "b").start();
    }
}

class phone {
    public synchronized void sms() {
        System.out.println(Thread.currentThread().getName() + "=>发短信");
        //这里也有锁
        call();
    }

    public synchronized void call() {
        System.out.println(Thread.currentThread().getName() + "=>打电话");
    }
}
